using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
namespace BusinessObjects.BO_GetObjects {
    public static class BO_portal_deals {
        public static DataTable SelectAll(int status) {
            try {
                usp_portal_deals_select_all entity = new usp_portal_deals_select_all();
                entity.STATUS = status;
                return BO_Actions<usp_portal_deals_select_all>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status) {
            try {
                usp_portal_deals_select_top entity = new usp_portal_deals_select_top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;
                return BO_Actions<usp_portal_deals_select_top>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable Search(int deal_id) {
            try {
                usp_portal_deals_search entity = new usp_portal_deals_search();
                entity.DEAL_ID = deal_id;

                return BO_Actions<usp_portal_deals_search>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status) {
            try {
                usp_portal_deals_select_paged entity = new usp_portal_deals_select_paged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                return BO_Actions<usp_portal_deals_select_paged>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static string Insert(int category_id, int region_id, Int64 member_id, int deal_type_id, string deal_code, string thumb_img, string title, string description, string deal_details, string meta_keywords, string meta_description, int total_comments, DateTime last_comment_date, string last_comment_by, int total_vote, int total_view, bool is_display, bool is_vip, DateTime vip_start_date, DateTime vip_end_date, int order_display, int order_display_in_category, decimal origin_price, decimal sale_price, decimal down_price_in_percent, bool is_finish, DateTime approved_date, string approved_by, DateTime publish_date, DateTime end_publish_date, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status) {
            try {
                usp_portal_deals_insert entity = new usp_portal_deals_insert();
                entity.CATEGORY_ID = category_id;
                entity.REGION_ID = region_id;
                entity.MEMBER_ID = member_id;
                entity.DEAL_TYPE_ID = deal_type_id;
                entity.DEAL_CODE = deal_code;
                entity.THUMB_IMG = thumb_img;
                entity.TITLE = title;
                entity.DESCRIPTION = description;
                entity.DEAL_DETAILS = deal_details;
                entity.META_KEYWORDS = meta_keywords;
                entity.META_DESCRIPTION = meta_description;
                entity.TOTAL_COMMENTS = total_comments;
                entity.LAST_COMMENT_DATE = last_comment_date;
                entity.LAST_COMMENT_BY = last_comment_by;
                entity.TOTAL_VOTE = total_vote;
                entity.TOTAL_VIEW = total_view;
                entity.IS_DISPLAY = is_display;
                entity.IS_VIP = is_vip;
                entity.VIP_START_DATE = vip_start_date;
                entity.VIP_END_DATE = vip_end_date;
                entity.ORDER_DISPLAY = order_display;
                entity.ORDER_DISPLAY_IN_CATEGORY = order_display_in_category;
                entity.ORIGIN_PRICE = origin_price;
                entity.SALE_PRICE = sale_price;
                entity.DOWN_PRICE_IN_PERCENT = down_price_in_percent;
                entity.IS_FINISH = is_finish;
                entity.APPROVED_DATE = approved_date;
                entity.APPROVED_BY = approved_by;
                entity.PUBLISH_DATE = publish_date;
                entity.END_PUBLISH_DATE = end_publish_date;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return BO_Actions<usp_portal_deals_insert>.ExecuteAndReturnStringValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static string Update(Int64 deal_id, int category_id, int region_id, Int64 member_id, int deal_type_id, string deal_code, string thumb_img, string title, string description, string deal_details, string meta_keywords, string meta_description, int total_comments, DateTime last_comment_date, string last_comment_by, int total_vote, int total_view, bool is_display, bool is_vip, DateTime vip_start_date, DateTime vip_end_date, int order_display, int order_display_in_category, decimal origin_price, decimal sale_price, decimal down_price_in_percent, bool is_finish, DateTime approved_date, string approved_by, DateTime publish_date, DateTime end_publish_date, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status) {
            try {
                usp_portal_deals_update entity = new usp_portal_deals_update();
                entity.DEAL_ID = deal_id;
                entity.CATEGORY_ID = category_id;
                entity.REGION_ID = region_id;
                entity.MEMBER_ID = member_id;
                entity.DEAL_TYPE_ID = deal_type_id;
                entity.DEAL_CODE = deal_code;
                entity.THUMB_IMG = thumb_img;
                entity.TITLE = title;
                entity.DESCRIPTION = description;
                entity.DEAL_DETAILS = deal_details;
                entity.META_KEYWORDS = meta_keywords;
                entity.META_DESCRIPTION = meta_description;
                entity.TOTAL_COMMENTS = total_comments;
                entity.LAST_COMMENT_DATE = last_comment_date;
                entity.LAST_COMMENT_BY = last_comment_by;
                entity.TOTAL_VOTE = total_vote;
                entity.TOTAL_VIEW = total_view;
                entity.IS_DISPLAY = is_display;
                entity.IS_VIP = is_vip;
                entity.VIP_START_DATE = vip_start_date;
                entity.VIP_END_DATE = vip_end_date;
                entity.ORDER_DISPLAY = order_display;
                entity.ORDER_DISPLAY_IN_CATEGORY = order_display_in_category;
                entity.ORIGIN_PRICE = origin_price;
                entity.SALE_PRICE = sale_price;
                entity.DOWN_PRICE_IN_PERCENT = down_price_in_percent;
                entity.IS_FINISH = is_finish;
                entity.APPROVED_DATE = approved_date;
                entity.APPROVED_BY = approved_by;
                entity.PUBLISH_DATE = publish_date;
                entity.END_PUBLISH_DATE = end_publish_date;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return BO_Actions<usp_portal_deals_update>.ExecuteAndReturnStringValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static bool Delete(string ids, string spliter, int delete_type) {
            try {
                usp_portal_deals_delete entity = new usp_portal_deals_delete();
                entity.IDS = ids;
                entity.SPLITER = spliter;
                entity.DELETE_TYPE = delete_type;

                return BO_Actions<usp_portal_deals_delete>.ExecuteAndReturnBooleanValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static bool Restore(int deal_id) {
            try {
                usp_portal_deals_restore entity = new usp_portal_deals_restore();
                entity.DEAL_ID = deal_id;

                return BO_Actions<usp_portal_deals_restore>.ExecuteAndReturnBooleanValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable SelectAdmin(string keywords, int startIndex, int pageCount, int status, int category_id, int deal_type_id) {
            try {
                usp_portal_deals_select_admin entity = new usp_portal_deals_select_admin();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                entity.CATEGORY_ID = category_id;
                entity.DEAL_TYPE_ID = deal_type_id;
                entity.KEYWORDS = keywords;
                return BO_Actions<usp_portal_deals_select_admin>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static bool Active(int deal_id, bool active) {
            try {
                usp_portal_deals_active entity = new usp_portal_deals_active();
                entity.DEAL_ID = deal_id;
                entity.IS_DISPLAY = active;
                return BO_Actions<usp_portal_deals_active>.ExecuteAndReturnBooleanValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable GetLastest(int rows) {
            try {
                usp_portal_deals_select_lastest entity = new usp_portal_deals_select_lastest();
                entity.NUMBERRECORD = rows;
                return BO_Actions<usp_portal_deals_select_lastest>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable GetMostViewed(int rows) {
            try {
                usp_portal_deals_select_most_viewed entity = new usp_portal_deals_select_most_viewed();
                entity.NUMBERRECORD = rows;
                return BO_Actions<usp_portal_deals_select_most_viewed>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable GetDetails(Int64 deal_id) {
            try {
                usp_portal_deals_details entity = new usp_portal_deals_details();
                entity.DEAL_ID = deal_id;
                return BO_Actions<usp_portal_deals_details>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
		public static DataTable Filter(string keywords, int category_id, int startIndex, int records) {
            try {
                usp_portal_deals_filter entity = new usp_portal_deals_filter();
                entity.CATEGORY_ID = category_id;
                entity.KEYWORDS = keywords;
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = records;
                return BO_Actions<usp_portal_deals_filter>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable GetByCategoryID(int category_id, int startIndex, int records) {
            try {
                usp_portal_deals_select_by_category_id entity = new usp_portal_deals_select_by_category_id();
                entity.CATEGORY_ID = category_id;
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = records;
                return BO_Actions<usp_portal_deals_select_by_category_id>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
    }
}

